<?php
/**
* @desc 订单表单处理
* @author kevin.wang
* @date 2015-01-01 12:00:00
**/
class OrderDetailForm extends BaseForm
{
	public $goods_sn;
	public $sell_num;
	public $price;
	public $total_price;
	public $detail_status;
	public $pay_status;
	//表单规则
	public function rules()
	{
		return array(
			array('goods_sn, sell_num, price, total_price, detail_status, pay_status', 'required', 'message'=>'必填字段不能为空'),
			array('sell_num, price, total_price, pay_status', 'numerical', 'message'=>'购买份数、支付状态、订单金额、商品单价必须为数字'),
			array('detail_status', 'boolean', 'message'=>'订单状态为布尔值')
		);
	}
	//写入数据
	/*public function saveData(){
		$model = new Ptravel;
		$userInfo = json_decode(Yii::app()->session['userinfo'], true);
		$data = $this->attributes;
		$data['author'] = $userInfo['username'];
		return $model->insertPtravel($data);
	}*/
	//修改数据
	public function editData($data){
		if(empty($data)){
			return false;
		}
		$model = new Order;
		foreach($data as $value){
			$id = $value['order_detail_id'];
			unset($value['order_detail_id']);
			$this->attributes = $value;
			if(!$this->validate()){
				return false;
			}
			$model->editChildOrder($id, $this->attributes);
		}
		return true;
	}
}
